package nz.ac.massey.cs.webtech.s_15273550.server;

import java.util.ArrayList;
import java.util.List;

public class Dealer {
    //
    private List<Card> cardsInHand;

    public Dealer() {
        cardsInHand = new ArrayList<Card>();
    }

    public List<Card> getCardsInHand() {
        return cardsInHand;
    }

    public void setCardsInHand(List<Card> cardsInHand) {
        this.cardsInHand = cardsInHand;
    }

    //
    public void showCardsWithHidden() {
        System.out.println("dealer's hands:");
        int i = 1;
        System.out.println("1." + "unknown");
        System.out.println("2." + cardsInHand.get(1).transferColor() + " " + cardsInHand.get(1).transferPoint());
    }

    //
    public void showCards() {
        System.out.println("dealer's hands: points: " + getTotalPoints());
        int i = 1;
        for (Card card : cardsInHand) {
            System.out.println(i++ + "." + card.transferColor() + " " + card.transferPoint());
        }
    }
    //
    public void clear() {
        cardsInHand = new ArrayList<Card>();
    }

    //
    public int getTotalPoints() {
        int sum = 0;
        for (Card card : cardsInHand) {
            if (cardsInHand.size()==2 && card.getPoint() == 1){
                sum += 11;
            }else{
                sum += card.getPoint() > 10 ? 10 : card.getPoint();
            }
        }
        return sum;
    }
}


